package com.qfedu.job;

import com.qfedu.pojo.User;
import com.qfedu.service.UserService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.Random;

/**
 * 概述:
 *
 * @Author: Tbh
 * @Date: 2022/6/21 21:06
 */
public class MyJob implements Job {

    @Autowired
    private UserService userService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        System.out.println("Execute...."+new Date());

        User user = new User();
        Random random = new Random();
        user.setUserName("jack" + random.nextInt(100000));
        user.setAge(random.nextInt(80));
        user.setPassword("1111");
        userService.addUser(user);
    }
}
